﻿// =================================================================== 
// 业务逻辑层(GDIT.BLL)
//====================================================================
// 文件：BKeyWord.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
//引用DevExpress.Data.Filtering，DevExpress.Xpo程序集
// 程序集介绍：关键字操作逻辑
// ===================================================================
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using GDIT.Base.LogHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDIT.Model;

namespace GDIT.BLL
{
    public class BKeyWord
    {
        private Pattern.DALAbstractFactory dataFactory = DataProvider.defaultProvider;

        /// <summary>
        /// 查询并返回关键字集合
        /// </summary>
        /// <param name="word">需要查询的关键字</param>
        /// <returns></returns>
        public string[] SelectKeyWordByKeyWord(string keyword, int displaycount)
        {
            XPCollection xp = dataFactory.DALKeyWordProvider.SelectKeyWordByKeyWord(keyword);
            List<string> results = new List<string>(displaycount);
            foreach (Mtb_BullentinKeyWord keyWord in xp)
            {
                results.Add(keyWord.AritlceKeyWord);
            }
            return results.ToArray();
        }

        /// <summary>
        /// 查询并返回所有的文章关键字
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="displaycount"></param>
        /// <returns></returns>
        public string[] SelectAllArticleKeyWord(string keyword, int displaycount)
        {
            List<string> results = new List<string>(displaycount);
            results.AddRange(SelectKeyWordByKeyWord(keyword, displaycount));
            results.AddRange(SelectCollegeKeyWord(keyword, displaycount));
            return results.ToArray();
        }

        /// <summary>
        /// 查询并返回关键字集合
        /// </summary>
        /// <param name="word">需要查询的关键字</param>
        /// <returns></returns>
        public string[] SelectCollegeKeyWord(string keyword, int displaycount)
        {
            XPCollection xp = dataFactory.DALKeyWordProvider.SelectCollegeKeyWord(keyword);
            List<string> results = new List<string>(displaycount);
            foreach (Mtb_CollegeKeyWord keyWord in xp)
            {
                results.Add(keyWord.AritlceKeyWord);
            }
            return results.ToArray();
        }
    }
}
